package xyz.xtt.activity.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import xyz.xtt.activity.constants.ActivityCache;
import xyz.xtt.activity.entity.TblFragment;
import xyz.xtt.activity.mapper.TblFragmentMapper;
import xyz.xtt.activity.service.ITblFragmentService;
import xyz.xtt.common.starter.cache.CacheManager;

/**
 * @author dale
 * @date 2025/1/16
 **/
@Service
public class TblFragmentServiceImpl extends ServiceImpl<TblFragmentMapper, TblFragment> implements ITblFragmentService {
	@Autowired
	private CacheManager cacheManager;

	@Override
	public TblFragment infoWithFragmentKey(Integer fragmentKey) {
		return cacheManager.cacheObj(() -> {
			LambdaQueryChainWrapper<TblFragment> query = new LambdaQueryChainWrapper<>(baseMapper);
			return query.eq(TblFragment::getFragmentKey, fragmentKey).one();
		}, ActivityCache.INFO_FRAGMENT_KEY, String.valueOf(fragmentKey));

	}

}
